package com.main.hotel.controller;

import com.main.hotel.entity.Manager;
import com.main.hotel.entity.RoomType;
import com.main.hotel.service.ManagerService;
import com.main.hotel.service.RoomTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.util.Date;

@Controller
public class MainManagerController {
    @Autowired
    private ManagerService managerService;
    @Autowired
    private RoomTypeService roomTypeService;

    @RequestMapping("/manager_login")//访问路径：http://localhost:8080/index
    public String manager_login()
    {
        return "manager_login";
    }
    @RequestMapping("/manager_register")
    public String managerRegister()
    {
        return "manager_register";
    }
    @RequestMapping("/base")//访问路径：http://localhost:8080/base
    public String base()
    {
        return "base";
    }
    @RequestMapping("/manager_index")//访问路径：http://localhost:8080/manager_index
    public String manager_index()
    {
        return "manager_index";
    }
    @RequestMapping("/roomtype")//访问路径：http://lo calhost:8080/roomtype
    public String roomtype()
    {
        return "roomtype";
    }
    @RequestMapping("/manage")//访问路径：http://lo calhost:8080/roomtype
    public String manage()
    {
        return "manage";
    }
    @RequestMapping("/checkin")//访问路径：http://localhost:8080/checkin
    public String checkin() {
        roomTypeService.initRoomNum();
        roomTypeService.initNameByRoomType_id();
        return "checkin";
    }
    @RequestMapping("/checkout")//访问路径：http://localhost:8080/checkout
    public String checkout() {
        return "checkout";
    }
    @RequestMapping("/addmanager")
    @ResponseBody
    public String addCustomer(Manager manager)
    {
        Date date=new Date();
        System.out.println(date.toString());
        manager.setCreate_time(date);
        int result=managerService.addManager(manager);
        if(result==1)
            return "true";
        else
            return "false";
    }



}
